home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / jmod310.zip / SHOW.C < prev    next >
Text File  |  1991-11-30  |  2KB  |  57 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*   This program shows that JMODEM will execute without crashing the       */
  4. /*   system from a DOS Shell executed from any properly written BBS         */
  5. /*   system or BBS window. This program allocates memory just like BBS      */
  6. /*   systems do, it writes to the memory, then spawns JMODEM as a sub-      */
  7. /*   process from a DOS Shell ( Microsoft C _system(); ). Then it returns   */
  8. /*   and the parent process again writes to memory. The program then exits  */
  9. /*   to DOS. There will ne NO errors and NO crashes.                        */
  10. /****************************************************************************/
  11.  
  12. #include <stdio.h>           /* for _puts()   */
  13. #include <stdlib.h>          /* for _system() */
  14. #if defined (TURBOC)
  15.     #include <alloc.h>
  16. #else
  17.     #include <malloc.h>          /* for _malloc() */
  18. #endif
  19.  
  20. void main(void);
  21.  
  22.  
  23. #define BYTES 61000
  24.  
  25. void main ()
  26. {
  27.     unsigned short i;
  28.     unsigned char *memory;
  29.  
  30.     /*  Get some memory (a lot)  */
  31.     memory = (unsigned char *) malloc((unsigned short)BYTES);
  32.     if (!memory)
  33.     {
  34.        puts ("Memory allocation failed!");
  35.        return;
  36.     }
  37.  
  38.     system ("CLS");
  39.     puts ("I am writing to memory I own ...");
  40.  
  41.     for (i = 0; i< BYTES; i++)
  42.         *memory++ = (unsigned char) i;        /* Write to the memory */
  43.  
  44.     puts ("Now I'll execute JMODEM ...");
  45.     puts ("Type CTRL-BRK to exit from JMODEM (it will take 5 seconds)....");
  46.     for (i=0; i<18; i++)
  47.         puts("JMODEM JMODEM JMODEM JMODEM JMODEM JMODEM JMODEM JMODEM");
  48.  
  49.     system("JMODEM S1 NUL");
  50.  
  51.     for (i = 0; i< BYTES; i++)
  52.         *(--memory) = (unsigned char) i;    /* Write to the memory again */
  53.  
  54.     puts ("\nAs you can see, the system did not crash ....");
  55.     free (memory);
  56. }
  57.